package com.usefullc.extinguisher.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.usefullc.common.util.BeanUtils;
import com.usefullc.common.vo.AxisItemVo;
import com.usefullc.common.vo.AxisVo;
import com.usefullc.common.vo.AxisWrapperVo;
import com.usefullc.extinguisher.domain.FireDeviceAuditRecord;
import com.usefullc.extinguisher.param.FireDeviceAuditRecordParam;
import com.usefullc.extinguisher.query.FireDeviceAuditRecordQuery;
import com.usefullc.extinguisher.service.FireDeviceAuditRecordService;
import com.usefullc.extinguisher.service.FireDeviceAuditStatService;
import com.usefullc.extinguisher.vo.FireDeviceAuditRecordVo;
import com.usefullc.extinguisher.vo.FireDeviceAuditStatVo;
import com.usefullc.extinguisher.vo.IndexChartVo;
import com.usefullc.system.controller.BaseController;
import com.usefullc.system.controller.WebResultBuilder;
import com.usefullc.system.entity.Pager;
import com.usefullc.system.entity.WebResult;
import com.usefullc.system.param.IdsParam;
import com.usefullc.system.validator.UsefulValid;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.usefullc.system.controller.WebResultBuilder.successResult;

/**
 * 设备检查作业记录控制类
 * @author: 星空
 * @date: 2022-09-08
 */
@RestController
@RequestMapping("/extinguisher/fireDeviceAuditStat/")
@Api( tags="设备检查汇总")
public class FireDeviceAuditStatController extends BaseController {

    @Autowired
    private FireDeviceAuditStatService fireDeviceAuditStatService;

    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "设备检查汇总列表",response = WebResult.class)
    @GetMapping(path = "list",produces = "application/json")
    public WebResult list() {
        List<FireDeviceAuditStatVo> dataList = fireDeviceAuditStatService.list();
        return WebResultBuilder.successResult(dataList);
    }

    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "设备检查汇总历史列表", response = WebResult.class)
    @GetMapping(path = "hisList", produces = "application/json")
    public WebResult listAll(@UsefulValid(query = true) FireDeviceAuditRecordQuery query) {
        Pager<FireDeviceAuditStatVo> pager = fireDeviceAuditStatService.listHisPage(query.getJobId());
        return WebResultBuilder.successResult(pager);
    }


    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "设备检查首页报表统计", response = WebResult.class)
    @GetMapping(path = "getIndexChart", produces = "application/json")
    public WebResult getIndexChart(@UsefulValid(query = true) FireDeviceAuditRecordQuery query) {
        IndexChartVo indexChartVo = fireDeviceAuditStatService.getIndexChartVo();
        return WebResultBuilder.successResult(indexChartVo);
    }


    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "设备检查趋势图表", response = WebResult.class)
    @GetMapping(path = "auditTrendChart", produces = "application/json")
    public WebResult auditTrendChart(@UsefulValid(query = true) FireDeviceAuditRecordQuery query) {
        AxisWrapperVo axisWrapperVo = fireDeviceAuditStatService.auditTrendChart(query);
        return WebResultBuilder.successResult(axisWrapperVo);
    }


    @ApiOperationSupport(author = "Sampson@usefullc.com")
    @ApiOperation(value = "设备数量列表", response = WebResult.class)
    @GetMapping(path = "deviceNumList", produces = "application/json")
    public WebResult deviceNumList() {
        List<Map<String, Object>> dataList = fireDeviceAuditStatService.deviceNumList();
        return WebResultBuilder.successResult(dataList);
    }






}
